<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="common/common_head :: commonHeader('点价物料记录')"/>
    <link rel="stylesheet" th:href="@{/static/js/plugins/jquery-layout/jquery.layout-latest.css}">
</head>
<body class="gray-bg">
<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-condition">
            <form id="pricingMaterialForm" th:action="@{/pointPrice/list}" class="form-inline">
                <div class="select-list">
                    <ul>
                        <li class="col-sm-3"
                            shiro:hasPermission="pricingMaterial:materialCode">
                            <label>物料号: </label>
                            <input type="text" name="materialCode"/>
                        </li>
                        <li class="col-sm-3">
                            <label>物料描述：</label>
                            <input type="text" name="materialDesc"/>
                        </li>
                        <li class="col-sm-3">
                            <button id="pricingMaterialSearchBtn" type="button"
                                    class="btn btn-primary btn-rounded btn-sm"><i
                                    class="fa fa-search"></i>&nbsp;搜索
                            </button>
                            <button class="btn btn-warning btn-rounded btn-sm" type="reset"><i class="fa fa-eraser"></i>&nbsp;重置
                            </button>
                            <button id="pricingMaterialAdvancedSearch" type="button"
                                    class="btn btn-primary btn-rounded btn-sm" style="display: none"><i
                                    class="fa fa-caret-down"></i>&nbsp;高级搜索
                            </button>
                        </li>
                    </ul>

                </div>
            </form>
        </div>
        <div class="col-sm-12 select-info">
            <div class="btn-group hidden-xs toolbar" id="pricingMaterialToolBar" role="group">
                <a class="btn btn-outline btn-success btn-rounded" onclick="toAddpointPrice()"
                   shiro:hasPermission="pricingMaterial:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-outline btn-danger btn-rounded" onclick="toDeletepointPrice()"
                   shiro:hasPermission="pricingMaterial:delete">
                    <i class="fa fa-trash-o"></i> 删除
                </a>
            </div>
            <table id="pricingMaterial"></table>
        </div>
    </div>
</div>
<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<script type="text/javascript" th:src="@{/static/js/plugins/jquery-layout/jquery.layout-latest.js}"></script>

<!-- Page-Level Scripts -->

<!--  -->
<script type="text/javascript">
    //面向对象
    var searcherBS = Searcher.createBS('#pricingMaterial',
        [
            {checkbox: true},
            {title: '物料号', field: 'materialCode'},
            {title: '物料描述', field: 'materialDesc'},
            {title: '创建时间', field: 'createDate'},
        ]
    );

    //初始化所有字典数据
    initDictDataSel();

    /**
     * 查询数据
     */
    function refresh() {
        searcherBS.refresh();
    }


    /**
     * 跳转至新增页
     */
    function toAddpointPrice() {
        var index = Dialog.openUrl("新增信息记录", ctxPath + '/modules/inforecord/pricing_material_add.html',
            {
                area: ['900px', '700px'],
                maxmin: true,
                end: function () {
                }
            });
        layer.full(index);
    }

    /**
     * 删除信息
     */
    function toDeletepointPrice() {
        //获取id
        var pkIds = searcherBS.getSelectedRows("pkId");
        if (pkIds.length < 1) {
            Dialog.errorMsg("请选择要删除的信息");
            return false;
        }
        var materialCodes = searcherBS.getSelectedRows("materialCode").toString();
        var pkId = pkIds.toString();
        Dialog.confirm('确定删除？', function (index) {
            Page.ajaxPOST(ctxPath + "/pointPrice/deletePrice", {
                pkIds: pkId,
                materialCode: materialCodes
            }, function () {
                Dialog.msg("操作成功", function () {
                    searcherBS.refresh();
                });
            });
        });

    }


</script>
</body>